from .services import RegistryService

def display_menu():
    print("\n=== 学生花名册管理系统 ===")
    print("1. 录入学生")
    print("2. 查询学生")
    print("3. 退出系统")

def main():
    registry = RegistryService()
    
    while True:
        display_menu()
        # 命令行输入
        choice = input("请选择操作: ")
        
        if choice == '1':
            print("\n--- 录入新学生 ---")
            name = input("姓名: ")
            age = input("年龄: ")
            gender = input("性别: ")
            class_name = input("班级: ")
            
            student = registry.add_student(name, age, gender, class_name)
            print(f"\n 学生 {student.name} 已保存!")
        
        elif choice == '2':
            print("\n--- 查询学生 ---")
            name = input("输入要查询的姓名: ")
            student = registry.find_student(name)
            
            if student:
                print("\n找到学生信息:")
                print(f"姓名: {student.name}")
                print(f"年龄: {student.age}")
                print(f"性别: {student.gender}")
                print(f"班级: {student.class_name}")
            else:
                print("\n 未找到该学生")
        
        elif choice == '3':
            print("\n感谢使用, 再见! ")
            break
        
        else:
            print("\n 无效选项，请重新输入")

if __name__ == "__main__":
    main()